﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ATMSystem
{
    class Customer
    {
        string firstName;
        string lastName;
        int accountNumber;
        decimal actualMoney;

        public Customer(string firstName, string lastName)
        {
            this.firstName = firstName;
            this.lastName = lastName;
        }

        public Customer (string firstName, string lastName, decimal money) : this(firstName, lastName)
        {
            this.actualMoney = money;
        }

        public void CreateAccount(Bank b)
        {
            accountNumber = b.CreateAccount();
        }

        public void CloseAcount(Bank b)
        {
            actualMoney += b.CloseAccount(accountNumber);
            accountNumber = 0;
        }

        public void GetAccountBalance(Bank b)
        {
            b.GetAccountBalance(accountNumber);
        }

        public void GetMoney(Bank b, decimal money)
        {
            if (accountNumber <= 0)
            {
                Console.WriteLine("Для проведения операции необходимо открыть счет");
                return;
            }
                actualMoney += b.GiveMoney(accountNumber, money);
        }

        public void GiveMoney(Bank b, decimal money)
        {
            if (accountNumber <= 0)
            {
                Console.WriteLine("Для проведения операции необходимо открыть счет");
                return;
            }
            if (b.GetMoney(accountNumber, money))
            {
                actualMoney -= money;
            }
        }

        public override string ToString()
        {
            return String.Format("{0} {1}, сумма наличных {2}", firstName, lastName, actualMoney);
        }
    }
}
